Fix has_manifest_files failing to match root-level manifest files#168
Open
Fix has_manifest_files failing to match root-level manifest files#168
Conversation
PurePath.match("**/package.json") returns False for root-level files
in Python 3.12+ because ** requires at least one directory component.
The function was unconditionally prepending **/ to all patterns,
causing root-level manifests like package.json and package-lock.json
to never match. This forced every scan into full scan mode instead of
diff scan mode, which meant MR/PR comments were never posted.
Fix by trying the direct pattern match first, then falling back to
the **/ prefixed pattern for subdirectory matching.
Fixes Zendesk #2447
|
❌ Version Check Failed Please increment... |
|
🚀 Preview package published! Install with: pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.2.76.dev7Docker image: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
has_manifest_files()unconditionally prepends**/to patterns without/, then matches usingPurePath.match(). In Python 3.12+,PurePath("package.json").match("**/package.json")returnsFalsebecause**requires at least one directory component. Root-level manifest files (the common case) never match.This sets
has_supported_files=False, forcing every scan into full scan mode instead of diff scan mode. Full scans don't post MR/PR comments.Fix
Try the direct pattern match first (handles root-level files), then fall back to
**/prefixed pattern for subdirectory matching.Reproduction
package.jsonat the rootsocketcli --target-path . --enable-debug --enable-diffhas_supported_files=False, falls back to full scanhas_supported_files=True, proceeds with diff scanTest plan
socketdev/cli:latestDocker image Python versionFixes Zendesk #2447